package com.rickie.assembler;

import com.rickie.dto.event.CargoRoutedEvent;
import com.rickie.dto.event.CargoHandledEvent;
import com.rickie.dto.command.TrackingEventAddCmd;
import com.rickie.dto.command.TrackingNumberAssignCmd;
import com.rickie.model.valueobjects.TrackingEvent;

/**
 * @author rickie
 * @version 1.0.0
 * @ClassName TrackingCommandAssembler.java
 * @Description TODO
 * @createTime 2021年07月22日 20:56:00
 */
public class TrackingCommandAssembler {

    public static TrackingEvent toTrackingEvent(TrackingEventAddCmd cmd,int trackingId){
        return new TrackingEvent(
                trackingId,
                cmd.getVoyageNumber(),
                cmd.getLocation(),
                cmd.getEventType(),
                cmd.getEventTime()
        );
    }

    public static TrackingNumberAssignCmd toCommandFromEvent(CargoRoutedEvent event){
        return new TrackingNumberAssignCmd(
                event.getBookingId(), ""
        );
    }

    public static TrackingEventAddCmd toCommandFromEvent(CargoHandledEvent event){
        return new TrackingEventAddCmd(
                event.getBookingId(),event.getHandlingCompletionTime(),
                event.getEventType(), event.getHandlingLocation(),
                event.getVoyageNumber()
        );
    }
}
